package Operation;


import Book.BookDao;
import Book.book;

import java.util.Scanner;

public class AddOperation implements IOperation {
    @Override
    public void work() {
        System.out.println("新增书籍");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名");
        String bookName = scanner.next();
        System.out.println("请输入作者");
        String author = scanner.next();
        System.out.println("请输入价格");
        int price = scanner.nextInt();
        System.out.println("请输入类别");
        String type = scanner.next();
        book book = new book();
        book.setName(bookName);
        book.setPrice(price);
        book.setAuthor(author);
        book.setType(type);
        BookDao bookDao = new BookDao();
        boolean ret = bookDao.add(book);
        if (ret) {
            System.out.println("新增书籍成功");
        } else {
            System.out.println("新增书籍失败");
        }
    }
}
